<?
#####################################################
#  COPYRIGHT NOTICE
#####################################################
# In the following statements, the term "this 
# program" refers to all files associated with the
# execution and distribution of Adtrackz.
#
# This Program is Copyright 2004 Jonah Klimack.
# All Rights Reserved. 
#
# Selling the code for this program, modifying 
# and/or redistributing the code for this program
# in part or in whole over the Internet or in any 
# other medium is expressly forbidden. Violators
# will be prosecuted to the fullest extent of the law
# Copyright and header information may not be
# modified.
#
# This program is distributed "as is" and without 
# warranty of any kind, either express or implied.
# In no event shall the liability of Jonah Klimack 
# for any damages, losses and/or causes of 
# action exceed the total amount paid by the 
# user for this software.		
#####################################################
# DO NOT MODIFY ANYTHING IN THIS FILE
#####################################################


require "header.php";

?>

<p class="small" align="left">
Split Test > Add New
</p>

<p class="heading">
Split Testing
</p>

<p>
You can compare the effectiveness of different versions of your salesletter by employing a split-test.
<p>
To perform a standard A/B split test with AdTrackzGold, create 2 campaigns, one for each version of your salesletter, and then add them to a split test group using the form below. Do not advertise these campaigns anywhere, they are to be used for your split test only.
<p></p>
Direct your visitors to your split test tracking url (which will be provided). AdTrackzGold can either distribute all traffic to each campaign equally, or tag the visitor and show them only one campaign (see "tag visitor" below).
<p></p>
To see your results, click on statistics in the split test menu. You can display the stats for each split test group that you have created, and you'll instantly see which campaign has the higher conversion rate within each group.
</p>

<?
if ($action == "addnew")
{
	//save split test, do error checking first
	if (mysql_fetch_row(mysql_query("select name from adtrackz_split_test_groups where name='$new_split_test'")))
		error("$new_split_test is already taken. ");
	elseif (strlen($new_split_test) > 20)
		error("The name you've chosen is too long. There is a 20 character maximum. ");
	elseif (!$new_split_test)
		error("You did not enter a name for the new split test. ");
	elseif($length < 2)
		error("You must add at least 2 campaigns to a split test");
	else
	{
		if ($tag)
			$tag = "checked";
		mysql_query("insert into adtrackz_split_test_groups values ('','$new_split_test','$tag',now())");

		//save campaigns that belong to split test, with error checking first

		//get latest id so we can add campaigns
		$st_id = mysql_fetch_row(mysql_query("select max(ID) from adtrackz_split_test_groups"));

		//add from query string
		for($i=0;$i<$length;$i++)
		{
			$option = "option".$i;
			$campaign = $$option; //mysql query doesn't like $$option		
			$campaignID = mysql_fetch_row(mysql_query("select ID from adtrackz_campaigns where adcode='$campaign'"));
			mysql_query("insert into adtrackz_split_test_campaigns values('','$campaignID[0]','$st_id[0]')");
		}	

		alert ("$new_split_test has been added successfully!<br><br>Select below for your new split test tracking url:<br> <textarea cols=50 rows=2>http://$domain/$udirectory/st.php?s=$new_split_test</textarea><br><br>Click this link to test it: <a href=http://$domain/$udirectory/st.php?s=$new_split_test target=_new>http://$domain/$udirectory/st.php?s=$new_split_test</a></p>");
	}
}
?>

<p><u>Step 1: Create New Split Test</u></p>


<SCRIPT language=javascript src="jsfunctions.js"></SCRIPT>
<form method="get" name="modifyform" action="st_new.php">
<table width="90%" align="center">
<tr>
	<td>Split Test Name:</td>
	<td>
		<input type="text" name="new_split_test" maxlength="20">
	</td>
</tr>
<tr>
	<td>Tag Visitor?</td>
	<td>
		<input type="checkbox" name="tag" checked>
	</td>
</tr>
<tr>
	<td>&nbsp;</td>
	<td><span class=small>
	Keep this on if you want your visitor to see only one version of your salesletter.
	If you want to use the split test feature as a rotator, you can turn this off and your visitor will always be shown a random campaign within the split test group. 
	</span>
	</td>
</tr>
</table>


<p><u>Step 2: Add Campaigns to Split Test</u></p>

<table width="90%" align="center">
<tr>
	<td>all campaigns</td>
	<td>&nbsp;</td>
	<td>Your New Split Test</td>
</tr>
<tr>
	<td>
		<select multiple name="allcampaigns" size=10>
		<?		
		$campaigndata = mysql_query("select * from adtrackz_campaigns order by adcode asc");
		while($campaign1 = mysql_fetch_row($campaigndata))
			echo "<option value=\"$campaign1[2]\">$campaign1[2]</option>";
		?>
		</select>
	</td>
	<td>
		<input type="button" name="add" value="Add To Split Test ->" onclick="AddCampaign();"  >
		<br><br>
		<input type="button" name="remove" value="Remove From Split Test" onclick="RemoveCampaign();"  >
	<td>
		<select multiple name="campaigns" size=10>
		<?		
		$campaignIDs = mysql_query("select campaignID from adtrackz_split_test_campaigns where split_test_id='$id'");
		while($cID = mysql_fetch_row($campaignIDs))
		{			
			$campaigndata = mysql_fetch_row(mysql_query("select ID,adcode from adtrackz_campaigns where ID='$cID[0]'"));
			echo "<option value=\"$campaigndata[1]\">$campaigndata[1]</option>";
		}
		?>
		</select>
	</td>
</tr>
<tr>
	<td colspan="4" align="center"><br>
	<input type="hidden" name="action" value="addnew">
		<br><br>
		<input type="button" value="Add New Split Test" onclick="AddNew();"  >
	<td>
</tr>
</table>
</form>
<?
require "footer.php";
?>